home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / comm / misc / DevHandler10.lha / DevHandler.doc next >
Encoding:
Text File  |  1995-01-18  |  17.3 KB  |  455 lines

  1.  
  2.                               The DEV Handler 1.0
  3.  
  4.                  (c) 1995 Martin Mares, MJSoft System Software
  5.  
  6. ================================================================================
  7.  
  8.  
  9. Preface
  10. =======
  11.  
  12.    The DEV Handler package and its documentation are Copyright (c) Martin Mares,
  13. MJSoft System Software, Prague, Czech Republic.
  14.  
  15.    This  archive  can  be  freely  redistributed as long as all of its files are
  16. included   in   their   original   form  without  any  additions,  deletions  or
  17. modifications  (excluding addition of other README-style files and icons) and no
  18. more  than a nominal fee is charged for its distribution.  All copyright notices
  19. in  the  programs and accompanying documentation files must remain intact.  It's
  20. especially  forbidden  to add various '.displayme' files and BBS advertisements.
  21. This style of distribution is generally known as FREEWARE.
  22.  
  23.    Special  permission  is  given  to  Fred Fish to include this software on his
  24. "Fish  Disks".
  25.  
  26.    This  software  is  provided  "AS  IS"  without  warranty of any kind, either
  27. expressed  or  implied.   The author is not responsible for any damage caused by
  28. it.
  29.  
  30.  
  31. Introduction
  32. ============
  33.  
  34.    - UNIX has named consoles.  Amiga doesn't.  They're very useful when you need
  35. to  say which console is someone logged on (a good example are the who and write
  36. utilities).
  37.  
  38.    - UNIX has special files representing devices.  Amiga doesn't.   They're very
  39. useful  for  tar-like  programs  to  access the devices directly without knowing
  40. about  Amiga  device  concept  (by the way, the Amiga access is much more better
  41. than  the  one  in UNIX, because it's completely asynchronous, but sometimes you
  42. prefer simplicity even with lower efficiency).
  43.  
  44.    - UNIX consoles and special files have multiuser protection.  Amiga doesn't.
  45.  
  46.    - There was no console and AUX handler satisfying all my requirements.
  47.  
  48.    This handler tries to be a solution to all of these problems. It creates a
  49. disk-like volume named Devices containing devices of the following kinds:
  50.  
  51.     (1)  Consoles. Each console can have its own screen. Also borderless windows
  52.      and similar specialities are supported. You can open the screen and set
  53.      its parameters (including colors) without using any other tool.
  54.  
  55.     (2)  AUX devices. Something like console, but connected to a serial-like
  56.      device instead of a window. When the carrier is lost, EOF is sent to
  57.      all pending read requests and a break signal is sent to processes which
  58.      use the console.
  59.  
  60.     (3)  Softlinks. You can install a soft link to any file. Icons may be
  61.      handled this way. You can also make all your volumes to DEV:
  62.  
  63.     (4)  Raw access to devices. Both stream and block devices are supported.
  64.  
  65.  
  66. Installation and configuration
  67. ==============================
  68.  
  69.    Copy DEVHandler to your handler directory (usually L:) and create a mount
  70. entry for it (in DEVS:Mountlist or DEVS:DOSDrivers/DEV, according to system
  71. version you use):
  72.  
  73. DEV:    Handler = L:DEVHandler            /* Correct this path */
  74.     StackSize = 2048
  75.     Priority = 5
  76.     GlobVec = -1
  77.     Startup = S:DEVHandler.config        /* Or any name you want */
  78.  
  79.    Also copy the Force command somewhere you like to have it in.
  80.  
  81.    After these steps, it would be good to create the configuration file
  82. mentioned in the mount entry. This file is a normal text file with comments
  83. introduced by semicolons (everything from the first semicolon to the end of the
  84. line is ignored). It consists of definition blocks - one for each device.
  85.  
  86.    Possible parameters are listed here: (many of them may be omitted, the
  87. required ones are marked with [R])
  88.  
  89. (1) Screen definition:
  90.  
  91.    SCREEN <name>    [R]    Name of public screen (must be the first line)
  92.    WIDTH <n>            Screen width in pixels (default=as Workbench)
  93.    HEIGHT <n>            Screen height in pixels (default=as Workbench)
  94.    DEPTH <n>            Number of bitplanes (default=as Workbench)
  95.    TITLE <title>        Screen title
  96.    DISPLAYID <mode>        Display mode for this screen = MonitorType
  97.                 (0=default, $21000=PAL, $11000=NTSC, $31000=VGA,
  98.                 $41000=A2024, $61000=EURO72, $71000=EURO36,
  99.                 $81000=SUPER72, $91000=DBLNTSC, $A1000=DBLPAL)
  100.                 + $8000 for HIRES / $8020 for SUPERHIRES
  101.                 + $0004 for interlace
  102.                 + $0080 for halfbrite mode
  103.                 (for other idents see graphics/modeid.[ih])
  104.    BEHIND <b>            If active (set to 1), the screen is opened in
  105.                 behind the others.
  106.    AUTOSCROLL <b>        If active, the screen is autoscrolled if it's
  107.                 larger than the visible display.
  108.    COLOR0 <n>            RGB value for color #0 ($000 to $FFF)
  109.    COLOR1 <n>            RGB value for color #1 ($000 to $FFF)
  110.    COLOR2 <n>            RGB value for color #2 ($000 to $FFF)
  111.    COLOR3 <n>            RGB value for color #3 ($000 to $FFF)
  112.  
  113. (2) Console definition:
  114.  
  115.    CONSOLE <name>    [R]    Name of console device (must be the first line)
  116.    LEFT <n>            Left edge of the window (default=0)
  117.    TOP <n>            Top edge of the window (default=0)
  118.    WIDTH <n>            Width of the window (default=full screen)
  119.    HEIGHT <n>            Height of the window (default=full screen)
  120.    TITLE <s>            Window title (don't set for backdrop windows)
  121.    ACTIVE <b>            If active, the window is activated when opened
  122.    BORDERLESS <b>        If active, the window has no border
  123.    PUBSCREEN <name>        Open the window on the specified public screen
  124.    CLIP <b>            If active, console clipping is allowed
  125.    BUFSIZE <n>            Size of input buffer (default=512 bytes)
  126.    UNIXMODE <b>            If active, it behaves as on UNIX systems - if
  127.                 you type anything, the output is not suppressed.
  128.                 The only way to stop it is using of CTRL-S
  129.                 (XOFF), continue by CTRL-Q (XON).
  130.    HISTSIZE <n>            Size of history buffer (default=1024 bytes).
  131.                 If zero, no history is available.
  132.    RMBTRAP <b>            If active, the right mouse button is ignored
  133.                 and doesn't stop console output.
  134.  
  135. (3) AUX definition:
  136.  
  137.    AUX <name>        [R]    Name of AUX device (must be the first line)
  138.    DEVICE <name>    [R]    Name of device to be used for I/O
  139.    UNIT <n>            Device unit to be used (default=0)
  140.    FLAGS <n>            Device flags to be used (default=0)
  141.    BUFLEN <n>            Device buffer size (default set by the device)
  142.    BAUD <n>            Baud rate (default=9600)
  143.    BITS <n>            Number of data bits (default=8)
  144.    STOPBITS <n>            Number of stop bits (default=1)
  145.    SERFLAGS <n>            Flags for the serial device:
  146.                 $00=no parity, $01=even, $03=odd
  147.                 + $04 for RS-232 7-wire protocol
  148.                 + $10 for high-speed mode
  149.                 + $20 for shared access
  150.                 + $80 for XON/XOFF mode (default=$20)
  151.    CHECKCD <n>            Carrier will be tested. In case it's been lost,
  152.                 all read requests are returned with EOF, all
  153.                 writes are rejected with write error and breaks
  154.                 are sent to all users. (default=0)
  155.    TERM <n>            Terminal type: 0=Amiga, 1=Amiga with CR+LF,
  156.                 2=something which should work with VT100
  157.                 (default=0)
  158.    BUFSIZE <n>            Size of input buffer (default=512 bytes)
  159.    UNIXMODE <b>            If active, it behaves as on UNIX systems - if
  160.                 you type anything, the output is not suppressed.
  161.                 The only way to stop it is using of CTRL-S
  162.                 (XOFF), continue by CTRL-Q (XON).
  163.    HISTSIZE <n>            Size of history buffer (default=1024 bytes).
  164.                 If zero, no history is available.
  165.  
  166. (4) Softlink definition:
  167.  
  168.    LINK <name>        [R]    Name of the link (must be the first line)
  169.    DEST <s>        [R]    Link destination
  170.  
  171. (5) Raw device definition:
  172.  
  173.    RAWDEVICE <name>    [R]    Name of the device (must be the first line)
  174.    DEVICE <s>        [R]    System device to be used
  175.    UNIT <n>            Device unit (default=0)
  176.    FLAGS <n>            Device flags (default=0)
  177.    BUFMEMTYPE <n>        Memory type for I/O buffers (1=any, 3=chip,
  178.                 5=fast ; default=1)
  179.    BLOCKSIZE <n>        Size of one block (not specified or zero for
  180.                 stream devices)
  181.    BUFFER <n>            Buffer size in blocks (or bytes if stream dev)
  182.                 Stream devices have buffered only writes (or
  183.                 nothing if no buffer is specified). Block
  184.                 devices must have some buffer.
  185.    SIZE <n>            Device size in bytes (0=stream, -1=infinite,
  186.                 -2=autodetect via ReadGeometry command)
  187.    EXCLUSIVE <b>        If active, only one open at a time is allowed
  188.    UPDATE <b>            If active, the UPDATE command is sent after last
  189.                 write request. Use for trackdisk-like devices.
  190.    MOTOR <b>            If active, turn off drive motor after the device
  191.                 is closed. Use for trackdisk-like devices.
  192.    CLEAR <b>            If active, all device buffers are flushed (via
  193.                 the CLEAR command) when a read/write error is
  194.                 detected.
  195.    READCMD <n>            Device command number used for reading.
  196.                 (default=2=CMD_READ)
  197.    WRITECMD <n>            Device command number used for writing.
  198.                 (default=3=CMD_WRITE)
  199.  
  200. (6) Global parameters (can be used for any device)
  201.  
  202.    PERMANENT <b>        If active, the device is always in opened state.
  203.                 If not set, the device is activated when it's
  204.                 opened and deactivated when closed. (If you
  205.                 specify a permanent screen, it will be still
  206.                 open. If it is not permanent (default), it will
  207.                 be opened as soon as some console will try to
  208.                 use it.)
  209.    FROM <name>            Copy all settings from given device defined
  210.                 before this one. The device must be of the same
  211.                 type as the current one.
  212.  
  213.    Warning #1: Strings are not enclosed in quotes, even if they contain spaces.
  214.  
  215.    Warning #2: DEVHandler is not foolproof. If you specify incorrect values of
  216. some options, it might crash.
  217.  
  218.    If a fatal error in the config file is found, a small window is opened and
  219. the error is announced. After this, the handler exits normally.
  220.  
  221.    For some examples, see the example config file (DevHandler.config) in this
  222. archive.
  223.  
  224.  
  225. Differences
  226. ===========
  227.  
  228.    There are some differences between DEVHandler consoles and the standard CBM
  229. CON handler:
  230.  
  231.       - Large writes are split automatically allowing to stop any write between
  232.     lines.
  233.  
  234.       - Control sequences are buffered, so if you send a control sequence in two
  235.     consecutive writes, the console won't insert anything between them (in
  236.     standard CON, you can type a character inside it!).
  237.  
  238.       - If you use the RCOMMAND-V (paste) combination in raw mode, the control
  239.     sequence for pasting will be sent before the actually pasted data. It
  240.     makes the raw mode completely transparent (all data received from
  241.     console.device are sent to you, but some of them are also interpreted -
  242.     such as breaks and the paste).
  243.  
  244.       - CTRL-S and CTRL-Q act as normal XOFF and XON characters. (Used to stop
  245.     the output anywhere and to continue afterwards.)
  246.  
  247.       - UNIX mode may be activated. In this case, any line being edited doesn't
  248.     stop display output. Some people like it.
  249.  
  250.       - Buffer sizes and other useful constants may be set.
  251.  
  252.       - You can force EOF on the console using the Force command (see below).
  253.         You can use this feature if there's someone logged on your system and
  254.         you want to disconnect him. This command requires the ss.library
  255.         version 5.0 or higher (can be found on the AmiNet).
  256.  
  257.       - You can put the currently edited line to history buffer without sending
  258.     it to your program by pressing CTRL-B.
  259.  
  260.       - It's possible to delete not only words delimited by spaces, but also
  261.         words consisting only from letters, digits and underlines by CTRL-R.
  262.  
  263.       - All characters except $00 and $9B can be stored to the line. In the raw
  264.     mode, no restrictions on character codes apply.
  265.  
  266.       - You can Examine() the console. In this case, the datestamp returned
  267.     tells you when has then user typed the last character. (Useful for
  268.     WHO-like utilities.)
  269.  
  270.  
  271. Multiuser protection
  272. ====================
  273.  
  274.    If the multiuser.library is found, full multi-user protection mechanisms
  275. are applied:
  276.  
  277.    - There are no restrictions on screens
  278.  
  279.    - Console and AUX devices normally belong to root and are openable by anyone.
  280. In case first user opens the console, its owner is changed to that user. If it's
  281. released, the owner is set back to root.
  282.  
  283.    - Links are readable by anyone.
  284.  
  285.    - Raw devices act like normal files.
  286.  
  287.    Each device has usual protection bits. They may be altered by the current
  288. owner and are set back to the defaults when the device is closed. If root
  289. modifies the protections, they are set as the defaults.
  290.  
  291.    Access rights are cached on file open, therefore if you pass a filehandle to
  292. anyone, the access rights you had on open are used.
  293.  
  294.    If you are root or you're in the root group, you can do anything the owner
  295. of the file can. Some packets are available only to root.
  296.  
  297.    Default protection bits:
  298.  
  299.     CONSOLE/AUX    owner rw, group w, other w
  300.     LINK        all r
  301.     RAWDISK        owner rwd (The d bit is set because the copy command
  302.             duplicates protection bits and would generate undele-
  303.             table files.)
  304.  
  305. Supported packets
  306. -----------------
  307.  
  308.    This section lists all DOS packets handled by the DEVHandler. Each of these
  309. packets is described, its arguments and access right restrictions are listed.
  310.  
  311. (1) Standard packets for all devices:
  312.  
  313.    DIE() -> success                             [ONLY ROOT]
  314.    Shut down the handler. Rejected if you are not root or if there still remain
  315.    some locks.
  316.  
  317.    CURRENT_VOLUME() -> BPTR volume
  318.    Get current (and the only) volume.
  319.  
  320.    LOCATE_OBJECT(BPTR lock,BSTR name,LONG mode) -> BPTR lock
  321.    Create a lock.
  322.  
  323.    FREE_LOCK(BPTR lock) -> success
  324.    Free a lock.
  325.  
  326.    COPY_DIR(BPTR lock) -> BPTR lock
  327.    Duplicate a lock.
  328.  
  329.    SET_PROTECT(zero, BPTR lock, BSTR name, LONG mask) -> success    [ONLY OWNER]
  330.    Set protection bits. If you are root, the protections are set as a default.
  331.  
  332.    EXAMINE_OBJECT(BPTR lock, BPTR fib) -> success
  333.    EXAMINE_NEXT(BPTR lock, BPTR fib) -> success
  334.    Standard directory examination mechanism.
  335.  
  336.    DISK_INFO(BPTR infodata) -> success
  337.    Get information about current volume.
  338.  
  339.    INFO(BPTR lock,BPTR infodata) -> success
  340.    Get information about volume associated with given lock. DEVHandler gives
  341.    the same result for all locks.
  342.  
  343.    PARENT(BPTR lock) -> BPTR lock
  344.    Get parent of given lock.
  345.  
  346.    SAME_LOCK(BPTR lock1, BPTR lock2) -> result
  347.    Compare two locks (see dos/SameLock)
  348.  
  349.    READ(LONG arg1,APTR buffer,LONG size) -> size           [READ RIGHTS]
  350.    Read data from console/aux/raw device.
  351.  
  352.    WRITE(LONG arg1,APTR buffer,LONG size) -> size          [WRITE RIGHTS]
  353.    Write data to console/aux/raw device.
  354.  
  355.    FINDUPDATE(BPTR lock,BPTR fh,BPTR name) -> success      [READ OR WRITE RIGHTS]
  356.    FINDINPUT(BPTR lock,BPTR fh,BPTR name) -> success      [READ OR WRITE RIGHTS]
  357.    FINDOUTPUT(BPTR lock,BPTR fh,BPTR name) -> success      [READ OR WRITE RIGHTS]
  358.    Open a file. In case it's a console, the file handle is redirected to the
  359.    corresponding internal console handler.
  360.  
  361.    END(LONG arg1) -> success
  362.    Close a file.
  363.  
  364.    SEEK(LONG arg1,LONG offset,LONG mode) -> oldpos
  365.    Seek a file.
  366.  
  367.    IS_FILESYSTEM() -> TRUE
  368.  
  369.    SET_OWNER(zero, BPTR lock, BSTR name, LONG ugid) -> success        [ONLY OWNER]
  370.    Set owner of a file.
  371.  
  372.    READ_LINK(BPTR lock,STRPTR name,APTR buffer,LONG size) -> length
  373.    Read contents of a soft link.
  374.  
  375. (2) Standard packets for the console/AUX subhandlers. (If you want to use them,
  376. you must open the console and extract handler port from the file handle.)
  377.  
  378.    WAIT_CHAR(LONG ticks) -> ischar                   [READ RIGHTS]
  379.    Wait for character is available (returns after specified time with FALSE or
  380.    with TRUE as soon as some character is available).
  381.  
  382.    DISK_INFO(BPTR infodata) -> success                   [READ RIGHTS]
  383.    Return information about the console:
  384.  
  385.     infodata->id_DiskType = 'CON'<<8 if console, 'RAW'<<8 if con in RAW mode
  386.                 'CONA' if AUX, 'RAWA' if AUX in RAW mode
  387.     infodata->id_VolumeNode = Window (0 if AUX)
  388.     infodata->id_InUse = device IORequest
  389.  
  390.    READ(LONG arg1,APTR buffer,LONG size) -> size           [READ RIGHTS]
  391.    Read data from the console.
  392.  
  393.    WRITE(LONG arg1,APTR buffer,LONG size) -> size          [WRITE RIGHTS]
  394.    Write data to the console.
  395.  
  396.    SCREEN_MODE(LONG mode)                      [WRITE RIGHTS]
  397.    Switch the console to RAW mode or back (mode=TRUE if RAW, FALSE if not).
  398.  
  399.    CHANGE_SIGNAL(???, APTR task) -> APTR task              [WRITE RIGHTS]
  400.    Set task to send breaks to.
  401.  
  402.    FINDINPUT,FINDOUTPUT(BPTR lock,BPTR fh,BSTR name) -> success  [R or W RIGHTS]
  403.    Create a new filehandle for this console. (Used to duplicate a file handle,
  404.    for example by NewShell.)
  405.  
  406.    END(LONG arg1) -> success
  407.    Close a filehandle.
  408.  
  409.    STACK(LONG arg1,APTR buffer,LONG size) -> size     [READ AND WRITE RIGHTS]
  410.    Insert something into console buffer. It will be read before all other input.
  411.  
  412.    QUEUE(LONG arg1,APTR buffer,LONG size) -> size     [READ AND WRITE RIGHTS]
  413.    Insert something into console buffer. It will be read after all other input.
  414.  
  415. (3) Non-standard packets for the console:
  416.  
  417.    INHIBIT(BOOL flag) -> success                    [ONLY OWNER]
  418.    If flag=TRUE, the console will be blocked until the same packet with flag set
  419.    to FALSE. While in inhibited state, the device used by AUX is not touched and
  420.    no IORequests are active.
  421.  
  422.    FORCE() -> success                            [ONLY OWNER]
  423.    Force EOF on this console. All read requests are returned with EOF, all write
  424.    packets are rejected with error. Break is sent as if CTRL-C and CTRL-D was
  425.    pressed.
  426.  
  427.    CHANGE_TERM(LONG termtype) -> success                [ONLY OWNER]
  428.    Set terminal type to specified one (see DEVHandler.i: DHTERM_#?).
  429.  
  430.  
  431. Planned enhancements
  432. ====================
  433.  
  434.    - New packet ABORT(LONG arg1) which would try to abort any operation in
  435. progress. (It's sometimes needed to break an already sent console read packet
  436. on program exit.)
  437.  
  438.    - More keyboard commands for the console (e.g., program priority control)
  439.  
  440.    - Console scrollback
  441.  
  442.    - Some packet allowing dynamic creation of devices. (A telnet-daemon could
  443. use this feature.)
  444.  
  445.    - EXAMINE_FH, FH_FROM_LOCK and some other useful packets.
  446.  
  447.    - Setting of default protection bits and default owner in config file.
  448.  
  449.  
  450. Final words
  451. ===========
  452.  
  453.    Send bug reports, flames and suggestions to <mjsoft@k332.feld.cvut.cz>.
  454.  
  455.